import express from "express";
import path from "path";
import cookieParser from "cookie-parser";
import logger from "morgan";
import cors from "cors";
import { fileURLToPath } from "url";
import { dirname } from "path";

// 路由导入使用import
import indexRouter from "./routes/index.js";
import clientRouter from "./routes/servers/Client.js";
import baseSetRouter from "./routes/system/base_set.js";
import adminRouter from "./routes/admin.js";

import taskRouter from "./routes/tasks/my_task.js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const app = express();

app.use(cors());
app.use(logger("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());

app.use(express.static(path.join(__dirname, "public")));

app.use("/", indexRouter);
app.use("/client", clientRouter);
// 系统路由
app.use("/system/baseSet", baseSetRouter);
app.use("/admin", adminRouter);
app.use("/tasks", taskRouter);  


export default app;
